/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * IHMSimulatorAddQuotaDialog.java
 *
 * Created on 17 janv. 2011, 22:52:50
 */

package IHM;

import javax.swing.JOptionPane;

/**
 *
 * @author Pierre
 */
public class IHMSimulatorAddQuotaDialog extends javax.swing.JDialog {

    private IHMSimulator parent;

    /** Creates new form IHMSimulatorAddQuotaDialog */
    public IHMSimulatorAddQuotaDialog(IHMSimulator parent, boolean modal) {
        super(parent, modal);
        initComponents();
        this.parent = parent;
    }


    public void showPopup()
    {
        this.setLocationRelativeTo(parent);
        this.setVisible(true);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jTF_startHour = new javax.swing.JTextField();
        jTF_EndHour = new javax.swing.JTextField();
        jTF_StartCallerFloor = new javax.swing.JTextField();
        jTF_EndCallerFloor = new javax.swing.JTextField();
        jTF_StartTargetFloor = new javax.swing.JTextField();
        jTF_EndTargetFloor = new javax.swing.JTextField();
        jTF_Requests = new javax.swing.JTextField();
        jCB_EndDay = new javax.swing.JComboBox();
        jCB_startDay = new javax.swing.JComboBox();
        jLabel10 = new javax.swing.JLabel();
        jBtn_OK = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Ajout d'un quota");
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Ajout d'un quota");
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 10, 190, -1));

        jLabel2.setText("Heure de début :");
        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 40, 170, 25));

        jLabel3.setText("Heure de fin :");
        getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 70, 170, 25));

        jLabel4.setText("Jour de début :");
        getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 100, 170, 25));

        jLabel5.setText("Jour de fin :");
        getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 130, 170, 25));

        jLabel6.setText("Etage d'appel début :");
        getContentPane().add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 170, 170, 25));

        jLabel7.setText("Etage d'appel fin :");
        getContentPane().add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 200, 170, 25));

        jLabel8.setText("Etage de destination début :");
        getContentPane().add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 240, 170, 25));

        jLabel9.setText("Etage de destination fin :");
        getContentPane().add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 270, 170, 25));

        jTF_startHour.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        getContentPane().add(jTF_startHour, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 40, 150, 25));

        jTF_EndHour.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        getContentPane().add(jTF_EndHour, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 70, 150, 25));

        jTF_StartCallerFloor.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        getContentPane().add(jTF_StartCallerFloor, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 170, 150, 25));

        jTF_EndCallerFloor.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        getContentPane().add(jTF_EndCallerFloor, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 200, 150, 25));

        jTF_StartTargetFloor.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        getContentPane().add(jTF_StartTargetFloor, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 240, 150, 25));

        jTF_EndTargetFloor.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jTF_EndTargetFloor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTF_EndTargetFloorActionPerformed(evt);
            }
        });
        getContentPane().add(jTF_EndTargetFloor, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 270, 150, 25));

        jTF_Requests.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        getContentPane().add(jTF_Requests, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 310, 150, 25));

        jCB_EndDay.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "LUNDI", "MARDI", "MERCREDI", "JEUDI", "VENDREDI", "SAMEDI", "DIMANCHE" }));
        getContentPane().add(jCB_EndDay, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 130, 150, 25));

        jCB_startDay.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "LUNDI", "MARDI", "MERCREDI", "JEUDI", "VENDREDI", "SAMEDI", "DIMANCHE" }));
        getContentPane().add(jCB_startDay, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 100, 150, 25));

        jLabel10.setText("Nombre de requêtes :");
        getContentPane().add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 310, 170, 25));

        jBtn_OK.setText("OK");
        jBtn_OK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtn_OKActionPerformed(evt);
            }
        });
        getContentPane().add(jBtn_OK, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 350, 80, -1));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTF_EndTargetFloorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTF_EndTargetFloorActionPerformed

}//GEN-LAST:event_jTF_EndTargetFloorActionPerformed

    private void jBtn_OKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtn_OKActionPerformed

        try {
            int startHour = Integer.parseInt(jTF_startHour.getText());
            int endHour = Integer.parseInt(jTF_EndHour.getText());
            int startDay = jCB_startDay.getSelectedIndex();
            int endDay = jCB_EndDay.getSelectedIndex();
            int startCallerFloor = Integer.parseInt(jTF_StartCallerFloor.getText());
            int endCallerFloor = Integer.parseInt(jTF_EndCallerFloor.getText());
            int startTargetFloor = Integer.parseInt(jTF_StartTargetFloor.getText());
            int endTargetFloor = Integer.parseInt(jTF_EndTargetFloor.getText());
            int nbRequests = Integer.parseInt(jTF_Requests.getText());

            parent.addNewQuota(startHour, endHour, startDay, endDay, startCallerFloor, endCallerFloor, startTargetFloor, endTargetFloor,nbRequests);
            this.setVisible(false);

        } catch (Exception ex) {

            JOptionPane.showMessageDialog(this, "Tous les champs doivent être saisi avec des entiers.");
        }
    }//GEN-LAST:event_jBtn_OKActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBtn_OK;
    private javax.swing.JComboBox jCB_EndDay;
    private javax.swing.JComboBox jCB_startDay;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JTextField jTF_EndCallerFloor;
    private javax.swing.JTextField jTF_EndHour;
    private javax.swing.JTextField jTF_EndTargetFloor;
    private javax.swing.JTextField jTF_Requests;
    private javax.swing.JTextField jTF_StartCallerFloor;
    private javax.swing.JTextField jTF_StartTargetFloor;
    private javax.swing.JTextField jTF_startHour;
    // End of variables declaration//GEN-END:variables

}
